package com.example.demo.netty;

import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;


@ChannelHandler.Sharable
public class CustomChannelInBoundHandler extends SimpleChannelInboundHandler<String> {

    @Override
    protected void channelRead0 (ChannelHandlerContext channelHandlerContext, String obj) throws Exception {
        System.out.println(obj);
//        ByteBuf byteBuf = (ByteBuf) obj;
//        ByteBuf copyByteBuf = byteBuf.copy();
////        while (copyByteBuf.isReadable()) {
////            System.out.print((char) copyByteBuf.readByte());
////        }
//        int capacity = copyByteBuf.capacity();
//        System.out.println(capacity);
//        byte[] bytes = new byte[capacity];
//        copyByteBuf.readBytes(bytes);
//        System.out.println(Arrays.toString(bytes));
//        System.out.println(new String(bytes, "GBK"));
    }
}
